#ifndef _XDBASE_H_
#define _XDBASE_H_
#define XDB_PATH_MAX        1024
#define XDB_DISK_MAX        1024
typedef struct _XDISK
{
    int   status;
    int   total;
    int   groupid;
    int   nodeid;
    int   port;
    void  *db;
    off_t limit;
    off_t free;
    char disk[XDB_PATH_MAX];
}XDISK;
typedef struct _XDBSTATE
{
    int     nxdisks;
    XDISK   xdisks[XDB_DISK_MAX];
}XDBSTATE;
typedef struct _XDBIO
{
    int     fd;
    void    *map;
    off_t   end;
    off_t   size;
}XDBIO;
typedef struct _XDBASE
{
    XDBIO stateio;
    XDBSTATE *state;
    void *map;
    void *mutex;
    void *logger;
}XDBASE;
/* initialize XDB */
XDBASE *xdbase_init(char *path);
/* add disk */
int xdbase_add_disk(XDBASE *xdbase, char *disk, off_t limit, int port);
/* update disk limit */
int xdbase_update_disk(XDBASE *xdbase, int diskid, off_t limit);
/* del disk */
int xdbase_del_disk(XDBASE *xdbase, int diskid);
/* add data */
int xdbase_add_data(XDBASE *xdbase, int diskid, int64_t id, char *data, int ndata);
/* update data */
int xdbase_set_data(XDBASE *xdbase, int diskid, int64_t id, char *data, int ndata);
/* del data */
int xdbase_del_data(XDBASE *xdbase, int diskid, int64_t id);
/* get data */
int xdbase_get_data(XDBASE *xdbase, int diskid, int64_t id, char *data);
/* close XDB */
void xdbase_close(XDBASE *xdbase);
#endif
